package com.cr.admin.business.user.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.cr.admin.business.user.pojo.param.UserAddParam;
import com.cr.admin.business.user.pojo.param.UserUpdateParam;
import com.cr.admin.business.user.pojo.query.UserQuery;
import com.cr.admin.business.user.pojo.vo.UserVO;

import com.cr.admin.business.user.service.UserService;
import com.cr.common.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@Api(tags = "用户管理")
@RequestMapping("/api/bus/users")
public class UserController {
//
//    @Autowired
//    private UserService userService;

    @GetMapping
    @SaCheckPermission("bus:content:users:query")
    @ApiOperation(value = "查询用户列表")
    public JsonResult selectUser(@RequestParam(required = false) UserQuery userQuery){
//        List<UserVO> list = userService.selectUser(userQuery);
        return JsonResult.success();
    }

    @PostMapping("/save")
    @SaCheckPermission("bus:content:users:save")
    @ApiOperation(value = "新增用户")
    public JsonResult saveUser(@RequestBody UserAddParam userAddParam){
//        userService.saveUser(userAddParam);
        return JsonResult.success();
    }

    @PostMapping("/{userId}/reset_password")
    @SaCheckPermission("bus:content:users:update:password:{userId}")
    @ApiOperation(value = "重置密码")
    public JsonResult resetPassword(@PathVariable Long userId){
//        userService.resetPassword(userId);
        return JsonResult.success();
    }

    @PostMapping("/{userId}/delete")
    @SaCheckPermission("bus:content:users:delete:{userId}")
    @ApiOperation(value = "删除用户")
    public JsonResult deleteUser(@PathVariable Long userId){
//        userService.deleteUser(userId);
        return JsonResult.success();
    }

    @PostMapping("/{userId}/update-status/{status}")
    @SaCheckPermission("bus:content:users:update:status:{userId}:{status}")
    @ApiOperation(value = "更新用户状态")
    public JsonResult updateStatus(@PathVariable Long userId, @PathVariable String status){
//        userService.updateStatus(userId, status);
        return JsonResult.success();
    }

    @PutMapping("/update")
    @SaCheckPermission("bus:content:users:update")
    @ApiOperation(value = "更新用户信息")
    public JsonResult updateUser(@RequestBody UserUpdateParam userUpdateParam){
//        userService.updateById(userUpdateParam);
        return JsonResult.success();
    }
}

